package cn.hzking.gjmall.utils;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

public class TimeManagement {
	public static String exchangeStringDate(long time) throws ParseException {
	    DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		String date=format.format(time);
		if (date != null && date.length() >= 7) {
			String result = date.substring(0, 7);
			return result;
		}else{
			return null;
		}
	}
	public static String getDate(long time) throws ParseException {
	    DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		String date=format.format(time);
		return date;
	}
	public static String getMonthDate(long time) throws ParseException {
	    DateFormat format = new SimpleDateFormat("MM-dd");
		String date=format.format(time);
		return date;
	}
	public static String getTimes(long time) throws ParseException {
	    DateFormat format = new SimpleDateFormat("HH:mm");
		String date=format.format(time);
		return date;
	}
	public static String getExactTime(long time) throws ParseException {
	    DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String date=format.format(time);
		return date;
	}
	public static String getDetailDate(long time) throws ParseException {
	    DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		String date=format.format(time);
		return date;
	}
	public static String getChineseDate(long time) throws ParseException {
	    DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
		String date=format.format(time);
		String chineseDate=date.substring(0,4)+"年"+date.substring(5,7)+"月";
		return chineseDate;
	}
	public static String getChineseDetailDate(long time) throws ParseException {
	    DateFormat format = new SimpleDateFormat("yyyy年MM月dd日");
		String date=format.format(time);
		return date;
	}
	public static String getMixtime(long time) throws ParseException {
	    DateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
		String date=format.format(time);
		return date;
	}
	public static String getYearMonthDate(long time) throws ParseException {
	    DateFormat format = new SimpleDateFormat("yyyy年MM月");
		String date=format.format(time);
		return date;
	}
	public static String getMonthDatetime(long time) throws ParseException {
	    DateFormat format = new SimpleDateFormat("MM月dd日");
		String date=format.format(time);
		return date;
	}
	public static String getTime(long time) throws ParseException {
	    DateFormat format = new SimpleDateFormat("MM月dd日");
		DateFormat detailformat = new SimpleDateFormat("yyyy年MM月dd日");
		DateFormat yearformat = new SimpleDateFormat("yyyy");
		String year=yearformat.format(time);
		String currentyear=yearformat.format(System.currentTimeMillis());
		String date="";
		if(year.equals(currentyear)){
			date=format.format(time);
		}else{
			date=detailformat.format(time);
		}
		//String chineseDate=date.substring(0,2)+"月"+date.substring(3,5)+"日";
		return date;
	}
	public static String getMsgTime(long time) throws ParseException {
	    DateFormat format = new SimpleDateFormat("MM月dd日 HH:mm");
	    DateFormat detailformat = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
	    DateFormat yearformat = new SimpleDateFormat("yyyy");
		String date="";
		String year=yearformat.format(time);
		String currentyear=yearformat.format(System.currentTimeMillis());
		if(year.equals(currentyear)){
			date=format.format(time);
		}else{
			date=detailformat.format(time);
		}
		return date;
	}
}
